home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
ca29_3.zip
/
BBMAINT4.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-03-24
|
35KB
|
1,195 lines
;**** TRACE ON ; Debugging
;
; ----- COM-AND BBS file maintenance script (MAIL file)
; Commenced: 11/90 R.McG
; -----------------------------------------------------------------------
; Purpose:
; The script, named BBMAINT4.CMD, produces the main window for
; Mail functions of BBMAINT, and implements its functions. It is
; not directly callable itself.
; -----------------------------------------------------------------------
; Usage:
; N99 -> Text attribute value (Setup by BBMAINT.CMD)
; N98 -> BBMAINT Mainline cursor position
; N97 -> BBMAINT Mainline cursor position
; N96 -> our mainline cursor position
; N95 -> our mainline cursor position
; -----------------------------------------------------------------------
;
; This script is intended ONLY to be used for FCALL
;
IF NOT FCALLED
WOPEN 10,10,13,70 (cont) NOMAEsc
ATSAY 10,12 (cont) " BBS Mail "
ATSAY 11,12 (cont) " The script: "*"_SCRIPT"
ATSAY 12,12 (cont) " is not used by itself... it is called through BBMAINT"
ATSAY 13,26 (cont) " Press any key to continue "
;
; Wait a keypress
;
KEYGET S0 ; Wait for any key
WCLOSE ; Close open window
EXIT ; Terminate right here
ENDIF
GOSUB Mailfile ; Invoke function
FRETURN ; Return to caller
; -----------------------------------------------------------------------
; ----- NoMail: Inform that there's no BBS-Mail file to modify
;
NoMail:
WOPEN 10,10,13,70 (cont) NOMAEsc
ATSAY 10,12 (cont) " BBS MailDir "
ATSAY 11,12 (cont) " The file: "*S24&"\BBS-Mail"
ATSAY 12,12 (cont) " does not exist. Please create subdirectories first."
ATSAY 13,26 (cont) " Press any key to continue "
;
; Wait a keypress
;
KEYGET S0 ; Wait for any key
WCLOSE
NOMAEsc:
RETURN
; -----------------------------------------------------------------------
; ----- Subroutine: MailFile -> Update Mail directory
;
MailFile:
GOSUB NewMail ; Create if not there
IF NOT ISFILE S24&"\BBS-Mail"
GOSUB NoMail ; Inform there's no file
RETURN ; .. so we can't continue
ENDIF
;
; Open a new window
;
WOPEN 0,0 23,79 (defa) Mail_Esc
ATSAY 0,2 (defa) " BBS Mail "
ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
;
; Paint a new menu
;
MAFI100:
CLEAR ; Clear window
LOCATE 2,2
MESS " 1) Clean up mail directory"
MESS " 2) Delete notes older than ..."
MESS " 3) Read notes newer than ..."
MESS " 4) Post a new note"
MESS "──────────────────────────────────── "
MESS "Note: Alt-Q to edit a file"
MESS " Alt-F for a directory search"
MESS " Alt-F10 to shell to DOS"
MESS " "
MESS "──────────────────────────────────── "
MESS " "
MESS "Select item (carriage return = previous): "
CURSOR N96,N95 ; Read current cursor
;
; Wait for entry, and interpret
;
MAFI200:
LOCATE N96 N95 ; Reposition cursor
KEYGET S0 ; Wait for it
SWITCH S0 ; Act according to keyget
CASE "1"
GOSUB ClrMail
GOTO MAFI100 ; Repaint after this
ENDCASE
CASE "2"
GOSUB DelMail
GOTO MAFI100 ; Repaint after this
ENDCASE
CASE "3"
GOSUB ReadMail
GOTO MAFI100 ; Repaint after this
ENDCASE
CASE "4"
GOSUB Compose
GOTO MAFI200 ; This sub saves screen
ENDCASE
CASE "0d" ; c/r alone is exit
WCLOSE ; Close window...
RETURN ; and return to caller
ENDCASE
CASE "_NULL" ; ESC -> Null
WCLOSE ; Close window...
RETURN ; Leave Main routine
ENDCASE
CASE "2100" ; Alt-F
MANUAL "0x2100" ; Perform Dir cmd
ENDCASE
CASE "1000" ; Alt-Q
MANUAL "0x1000" ; Edit a file
ENDCASE
CASE "7100" ; Alt-F10
SHELL
DWINDOW 1,2,22,78; Reset dwindow after shell
LEGEND "_LEGEND" ; Redo the legend
ENDCASE
DEFAULT ; None of the above
SOUND 100,100 ; Bronx cheer
ENDCASE
ENDSWITCH
GOTO MAFI200 ; Repaint screen and ask again
;
; End of mail procedure
;
Mail_Esc:
S0 = "" ; Fake a null entry
RETURN ; Leave Mail routine
; -----------------------------------------------------------------------
; ----- ClrMail: Clear mail directory of unneeded entries
;
ClrMail:
FOPENI S24&"\BBS-Mail" TEXT
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S24&"\BBS-Mail"
GOSUB Error ; Report
RETURN ; And we're done
ENDIF
FOPENO S24&"\TempMail" TEXT
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S24&"\TempMail"
GOSUB Error ; Report
RETURN ; And we're done
ENDIF
;
; Initialize
;
CLEAR ; Clear window
N9 = 0 ; Count recs written
;
; Read loop (40 chars at a time to allow PRESERVE)
;
CLMA100:
READ S10 40 N0 ; Read a record
IF EOF GOTO CLMA200 ; Skip on EOF
IF STRCMP S10(0:0) "*" GOTO CLMA115 ; Copy comments
IF ZERO N0 GOTO CLMA115 ; Copy blank lines
;
; Test for the existence of the indicated file
;
CLMA110:
S0 = S24&"\"*S10(25:37) ; Make a file name
IF NOT ISFILE S0 ; Test existence
MESS S0*" does not exist - deleting record"
GOTO CLMA130 ; Remove entry
ENDIF
MESS S0*" exists - copying record"
;
; Count the write
;
CLMA115:
INC N9 ; Count recs written
;
; Copy record just read to output file
;
CLMA120:
PRESERVE S10 ; Save !'s and ^'s
WRITE S10 ; Write text
IF N0 LT 40 ; If we wrote end of record
WRITE "!" ; Finish w/cr/lf
GOTO CLMA100 ; And continue copying
ENDIF
READ S10 40 N0 ; Read remainder of rec
IF NOT EOF GOTO CLMA120 ; Skip if not eof
WRITE "!" ; Finish record
GOTO CLMA200 ; End of file
;
; Throw away the current record
;
CLMA130:
IF N0 LT 40 GOTO CLMA100
READ S10 40 N0 ; Read remainder of rec
IF NOT EOF GOTO CLMA130 ; Skip if not eof
;
; We have end-of-file
;
CLMA200:
WRITE "^Z" ; Finish ASCII file
FCLOSEO ; Close output
FCLOSEI ; Close input
DELETE S24&"\BBS-Mail" ; Delete original
RENAME S24&"\TempMail" S24&"\BBS-Mail"
IF ZERO N9 DELETE S24&"\BBS-Mail" ; Delete empty file
RETURN
; -----------------------------------------------------------------------
; ----- DelMail: Delete mail files older than some date...
; .. Note this only works through current and last year
;
DelMail:
FOPENI S24&"\BBS-Mail" TEXT
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S24&"\BBS-Mail"
GOSUB Error ; Report
RETURN ; And we're done
ENDIF
FOPENO S24&"\TempMail" TEXT
IF NOT SUCCESS ; Open failed
S0 = "Error opening: "*S24&"\TempMail"
GOSUB Error ; Report
GOTO DEMAErr ; And we're done
ENDIF
N9 = 0 ; Counter for recs written
;
; Initialize
; .. (N2 = # days to keep, N3 = today's julian dayno, N4 = current yr)
;
S0 = "Enter age in days of the oldest file to keep"
GOSUB Get_Number ; Ask for a value
IF FLAG(0) GOTO DEMAERR ; IF ESCAPE pressed...
IF N0 LE 0 N0 = 1 ; No negative dates
N2 = N0 ; Save value for later
DATE S0 1 ; get current date (mm/dd/yyyy)
N4 = S0(6:9) ; Save current year number
GOSUB Julian ; make Julian date from current date
N3 = N0 ; Save current julian day number
CLEAR ; Clear window
;
; Read loop (40 chars at a time to allow PRESERVE)
;
DEMA100:
READ S10 40 N10 ; Read a record
IF EOF GOTO DEMA200 ; Skip on EOF
IF STRCMP S10(0:0) "*" GOTO DEMA115 ; Copy comments
IF ZERO N10 GOTO DEMA115; Copy blank lines
;
; Test for the existence of the indicated file
;
DEMA110:
S1 = S24&"\"*S10(25:37) ; Make a file name
IF NOT ISFILE S1 ; Test existence
MESS S1*" does not exist - cleaning dir"
GOTO DEMA130 ; Remove entry
ENDIF
;
; Find the date of the file. NOTE: The years we limit this code
; .. to recognizing are the current and previous years.
;
FDATE S0 S1 1 ; Get the file's date into S0 (mm/dd/yyyy)
N5 = N4-S0(6:9) ; Compute # years difference fdate and cur yr
IF N5 LT 0 ; If file year is future....
MESS S1*" date is in the fut